import request from '@/helpers/request';
import { jsonPost, reqGet } from '@/helpers/request';
import apiConfig from '@/apiConfig';
import { omit } from 'lodash';

/**
 *
 * @param params
 * @param options
 * @returns {*}
 */
export async function findByCode(params, options = {}) {
  return reqGet(apiConfig.findByCode, params, options);
}

/**
 *
 * @param params
 * @param options
 * @returns {*}
 */
export async function findByAppCode(params, options = {}) {
  return reqGet(apiConfig.findByAppCode, params, options);
}

/**
 *
 * @param params
 * @param options
 * @returns {*}
 */
export async function findByFinderCode(params, options = {}) {
  return reqGet(apiConfig.findByFinderCode, params, options);
}

/**
 *
 * @param params
 * @param options
 * @returns {*}
 */
export async function findByDataCode(params, options = {}) {
  return reqGet(apiConfig.findByDataCode, params, options);
}

/**
 * 获取带有分页的【查找器】数据
 * @param params
 * @param options
 * @returns {*}
 */
export async function findObjectList(params, options = {}) {
  return reqGet(params.reqApi, { size: 9999, ...omit(params, ['reqApi']) }, options);
}

/**
 * 获取行业信息
 * @returns {*}
 */
export async function findIndustry() {
  return reqGet(apiConfig.findIndustry);
}

/**
 * 获取解决方案
 * @returns {*}
 */
export async function findSolution() {
  return reqGet(apiConfig.findSolution);
}

/**
 * 获取解决方案
 * @returns {*}
 */
export async function findCurrency() {
  return reqGet(apiConfig.findCurrency);
}

/**
 * 重置密码
 * @returns {*}
 */
export async function resetPassword(params) {
  return jsonPost(apiConfig.resetPassword, {}, {
    params
  });
}
/**
 * 修改密码
 * @returns {*}
 */
export async function updatePassword(params) {
  return jsonPost(apiConfig.updatePassword, {}, {
    params
  });
}
/**
 *查找公司信息
 * @returns {*}
 */
export async function findCorpInfo(params) {
  const code={
    code:'GRP'
  }
  params=params||code
  return reqGet(apiConfig.findCorpInfo, {}, {
    params
  });
}

/**
 * 获取用户信息
 */
export async function findUserInfo(params) {
  return reqGet(apiConfig.userInfo, params);
}

/**
 * 获取用户信息
 */
export async function updateUserName(params) {
  return reqGet(apiConfig.updateName, params);
}

/**
 * 退出登录
 */
export async function logout() {
  return jsonPost(apiConfig.logout);
}

/**
 * 获取手机验证码
 * @returns {Promise<void>}
 */
export async function sendCaptcha(params, options = {}) {
  return jsonPost(apiConfig.sendCaptcha, params, options);
}


/**
 *目录列表
 * @param params
 * @param options
 * @returns {*}
 */
export async function findDocList(params, options = {}) {
  return reqGet(apiConfig.docListApi, params, options);
}

/**
 * 重命名 文件
 * @param params type 1目录 2文件
 * @param options
 *
 * @returns {*}
 */
export async function renameDoc(params, options = {}) {
  return reqGet(apiConfig.renameDocApi, params, options);
}

/**
 * 删除文件
 * @param params type 1目录 2文件
 * @param options
 * @returns {*}
 */
export async function deleteDoc(params, options = {}) {
  return reqGet(apiConfig.deleteDocApi, params, options);
}

/**
 * 创建文件夹
 * @param params
 * @param options
 * @returns {*}
 */
export async function createDoc(params, options = {}) {
  return jsonPost(apiConfig.createDocApi, params, options);
}

/**
 * 文件上传
 * @returns {*}
 */
export async function uploadDoc(params) {
  //console.log('params:',params);
  return request(apiConfig.documentUpload, params);
}

/**
 * 批量删除
 * ids
 * type 1:目录, 2:文件
 * @param params
 */
export async function batchDelDoc(params, options = {}) {
  //console.log('params:',params);
  return reqGet(apiConfig.batchDelDocApi, params, options);
}





